{template 'header'}
<link href="{MODULE_URL}template/css/css.css" rel="stylesheet" />
<link href="{MODULE_URL}template/css/stylesheet.css" rel="stylesheet" />
{if $op == 'display'}
<div class="top_menu">
    社区通知
</div>
<div class="top_menu_shadow"></div>
{loop $list $item}
<div class="fy">
	<a href="{php echo $this->createMobileUrl('announcement',array('id'=>$item['id'],'op'=>'detail'));}" class="sq_box notice">
        <div class="notice_title">

            <span class="haveread">{$item['title']}</span>
            

        </div>
        <div class="author_time">
            <div class="author">{php echo $this->module['config']['cname']}</div>
            <div class="time">{php echo date('Y-m-d', $item[createtime]);}</div>
        </div>

        <div class="notice_content">
        	{$item['datetime']}{$item['location']}{$item['reason']}
        	{$item['remark']}
        </div>
        <div class="notice_all">

            <span class="haveread">查看全部>></span>

        </div>
    </a>
</div>
{/loop}

<!-- <style type="text/css">
	a{
		color:black;
		font-size: 16px;
	}
	a:hover{
		text-decoration:none;
	}
</style>
<table class="table">
	<thead>
		<tr>
			<th>公告标题</th>
			<th style="width:110px; text-align:right;">发布时间</th>
		</tr>
	</thead>
	<tbody id='list'>
	{if empty($list)}
	<tr>
		<td colspan="2">没有任何公告</td>
	</tr>
	{/if}
	{loop $list $item}
		<tr>
			<td><a href="{php echo $this->createMobileUrl('announcement',array('id'=>$item['id'],'op'=>'detail'));}">
			{php echo cutstr($item['title'], 15, true);}</a></td>
			<td style="text-align:right; color:#888;">{php echo date('Y-m-d', $item[createtime]);}</td>
		</tr>
		{if !empty($member['manage_status'])}
		<tr>
			<td colspan=3 align='right'>    
				<a href="
				{php echo  $this->createMobileUrl('announcement',array('id' => $item['id'],'op' => 'delete'))}">删除</a>&nbsp;|&nbsp;
				<a href="{php echo  $this->createMobileUrl('announcement',array('id' => $item['id'],'op' => 'update'))}">修改</a>&nbsp;|&nbsp;
				{if $item['status'] == 1}
				<a href="
				{php echo $this->createMobileUrl('announcement',array('id' => $item['id'],'op' => 'verify','status' => 2,))}">启用</a>{else}
				<a href="
				{php echo $this->createMobileUrl('announcement',array('id' => $item['id'],'op' => 'verify','status' => 1,))}">禁用</a>{/if}
			</td>
		</tr>
		{/if}
	{/loop}
	</tbody>
</table> -->
<div style="display:none;left: 0px;top: 0px;width: 100%;height: 100%;overflow: hidden;position: fixed;background: rgba(0, 0, 0, 0.5);" id="layer">

</div>
	{if count($list)>9}
	<div style="margin-top:20px;margin-bottom:70px;text-align:center;font-size:16px;" id='view' >查看更多</div>
	{/if}
	{if !empty($member['manage_status'])}
		<div style='margin-top:50px;margin-left:60px;'>
		<a class="btn btn-primary" style="width:80%;" href="
			{php echo $this->createMobileUrl('announcement',array('op' => 'update'))}">发布公告</a>
		</div>
	{/if}
{/if}
{if $op == 'detail'}

<div class="sq_box notice" style="margin-top:20px;">
	<div class="page-header" style='margin-left:10px;margin-top:0px;'>
  		<h4>{php echo cutstr($item['title'], 20, true);} <small>{php echo date('Y-m-d', $item[createtime]);}</small></h4>
	</div>
	<div class="content" style='margin-left:10px;'>
		{$item['datetime']}{$item['location']}{$item['reason']}
        {$item['remark']}
	</div>
</div>
{/if}
{if $op == 'update'}
<div class='main'>
<form class="form-horizontal" role="form" method="post" action="{php echo $this->createMobileUrl('announcement',array('op' => 'update'))}">
	<input type="hidden" name="id" value="{$item['id']}" />
	<div class="panel panel-default">
	<div class="panel-heading">使用模板消息，必须是认证的服务号才可以，先到参数设置里面设置对应的场景模板消息ID。</div>
  		<div class="panel-body">
			 <div class="form-group">
					    <label for="title" class="col-sm-2 control-label">是否启用模板消息</label>
					    <div class="col-sm-4">
					      <label class="radio-inline">
							  <input type="radio" name="status" id="" value="2" {if $item['status'] == 2 || empty($item['status'])}checked="checked"{/if}> 是
							</label>
							<label class="radio-inline">
							  <input type="radio" name="status" id="" value="1" {if $item['status'] == 1 }checked="checked"{/if}> 否
							</label>
					    </div>
					</div>
					<div>
					<div class="form-group">
					    <label for="title" class="col-sm-2 control-label">模板消息类型</label>
					    <div class="col-sm-10">
					      	<label class="radio-inline">
							  <input type="radio" name="enable" id="" value="1" {if $item['enable'] == 1 || empty($item['status'])}checked="checked"{/if} > 停水通知
							</label>
							<label class="radio-inline">
							  <input type="radio" name="enable" id="" value="2" {if $item['enable'] == 2 }checked="checked"{/if}> 燃气通知
							</label>
							<label class="radio-inline">
							  <input type="radio" name="enable" id="" value="3" {if $item['enable'] == 3 }checked="checked"{/if}> 停电通知
							</label>
							<label class="radio-inline">
							  <input type="radio" name="enable" id="" value="4" {if $item['enable'] == 4 }checked="checked"{/if}> 门禁通知
							</label>
							<label class="radio-inline">
							  <input type="radio" name="enable" id="" value="5" {if $item['enable'] == 5 }checked="checked"{/if}> 电梯通知
							</label>
							<label class="radio-inline">
							  <input type="radio" name="enable" id="" value="6" {if $item['enable'] == 6 }checked="checked"{/if}> 停车场通知
							</label>
					    </div>
					</div>
					<div class="form-group">
					    <label for="title" class="col-sm-2 control-label">通知标题</label>
					    <div class="col-sm-6">
					      <input type="text" name="title" id='title' value="{$item['title']}" class="form-control" placeHolder="例：您好，很抱歉的告诉您小区将停止供应自来水一段时间。"/>
					    </div>
					</div>
					<div class="form-group">
					    <label for="title" class="col-sm-2 control-label">通知时间</label>
					    <div class="col-sm-6">
					      <input type="text" name="datetime" id='datetime' value="{$item['datetime']}" class="form-control" placeHolder="例：2015年4月25日8：00-2015年4月28日18:00"/>
					    </div>
					</div>
					<div class="form-group">
					    <label for="title" class="col-sm-2 control-label">通知范围</label>
					    <div class="col-sm-6">
					      <input type="text" name="location" id='location' value="{$item['location']}" class="form-control" placeHolder="例：A16栋-A18栋"/>
					    </div>
					</div>
					<div class="form-group">
					    <label for="title" class="col-sm-2 control-label">通知原因</label>
					    <div class="col-sm-6">
					    	<textarea name="reason" id='reason' class="form-control" placeHolder="例：管道检修">{$item['reason']}</textarea>
					    </div>
					</div>
					<div class="form-group">
					    <label for="" class="col-sm-2 control-label">通知备注</label>
					    <div class="col-sm-6">
					    	<input type="text" name="remark" id='remark' value="{$item['remark']}" class="form-control" placeHolder="例：请您提前准备，如有疑问可咨询13770331212"/>
					    </div>
					</div>
					<div class='form-group' style='text-align:center;'>
						<button type="submit" name="submit" value="yes" class="btn btn-primary" style="width:60%;">提交</button>
						<input type="hidden" name="token" value="{$_W['token']}" />
					</div>
		</div>
	</div>
</div>

</form>
</div>
{/if}
<script>
var page = 2;
$(function() {
    $(".reply-more-btn").click(function() {
        var a = $(this).parent(".reply");
        a.find(".reply-more").toggle();
        $(this).hide();
    });
    $("#view").click(function() {
        $('#layer').show();
        obj=$(this);
        $(this).html('正在加载中...')
        $.get("{php echo $this->createMobileUrl('announcement',array('op'=>'more'))}&page="+page, function(result){
                    if(result!=''){
                        $('#list').append(result);
                        page++;    
                        obj.html('查看更多');
                    }else{
                        obj.html('没有更多公告了');
                    }
                    $('#layer').hide();
            });
        });
});
</script>
{template 'footer'}